<%--
  Created by IntelliJ IDEA.
  User: 16014
  Date: 2022/5/14
  Time: 23:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>



<!DOCTYPE html>
<html lang="zh"  xmlns:th="http://www.thymeleaf.org">

<!DOCTYPE html>
<html lang="zh"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>个人信息 - Elvt个人博客</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="elvt, Elvt个人博客">
    <meta name="description" content= Elvt个人博客">
    <meta name="author" content="yinqi">
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="LightYear,">
    <meta name="description" content="elvtAssets Admin是一个基于elem+vue 后台管理系统。">
    <meta name="author" content="yinqi">
    <link href="../static/css/bootstrap.min.css" rel="stylesheet">
    <link href="../static/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="../static/css/style.min.css" rel="stylesheet">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="../static/js/util.js"></script>
    <link rel="stylesheet" href="../static/css/stylee.css">
</head>

<body>
</header>
<!--End 头部信息-->
<!--页面主要内容-->
<div id="app">
    <main class="lyear-layout-content">

        <div class="container-fluid">

            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">
                            <form method="POST" action="${pageContext.request.contextPath}/user" enctype="multipart/form-data" id="updateForm">
                                <div class="edit-avatar">

                                    <img src="http://localhost/myBolg/user?actionName=userHead&imageName=${user.head}" alt="..." class="img-avatar">
                                    <div class="avatar-divider"></div>
                                    <div class="edit-avatar-content">
                                        <label>选择新头像</label> <input type="file" name="img" value="选择新头像" id="img">
                                        <p class="m-0"></p>
                                    </div>
                                </div>
                                <hr>
                                <div class="form-group">
                                    <label for="actionName">ss</label>

                                    <input type="hidden" class="form-control" name="actionName" id="actionName"  value="updateUser">
                                </div>
                                <div class="form-group">
                                    <label for="nick">昵称</label>
                                    <input type="text" class="form-control" name="nick" id="nick" placeholder="请输入你的昵称！" value="${user.nick}">
                                    <span style="color: #ff0000 ;font-size: 12px" id="msg"></span>
                                </div>
                                <div class="form-group">
                                    <label for="mood">用户心情</label>
                                    <input type="text" class="form-control" name="mood" id="mood" placeholder="请输入你的心情！" value="${user.mood}">
                                </div>

<%--                                <div class="form-group">--%>
<%--                                    <label>邮箱：</label>--%>
<%--                                    <input type="text" class="form-control" name="" id="email" value="" disabled="disabled" />--%>
<%--                                </div>--%>
                                <input type="button" class="btn btn-primary" value="保存" id="btn" />

                            </form>
                        </div>
                    </div>
                </div>

            </div>

        </div>

    </main>
    <!--End 页面主要内容-->

</div>
</div>

<script type="text/javascript">
    var ss= $("#nick").val()
    var nickName;
    var moodvar;
    var imgs;

    $("#mood").blur(function () {
        imgs= $("#img").file()
        moodvar= $("#mood").val()
    })

    $("#nick").blur(function () {
         nickName= $("#nick").val()
        if (isEmpty(nickName)){
            $("#msg").html("昵称不能为空");
            $("#btn").prop("disabled",true);
            return;
        }
        if (nickName==ss){
            return;
        }
        $.ajax({
            type:"post",
            url:"/myBolg/user",
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            data:{
                actionName:"checkNick",
                nick:nickName
            },
                success:function (result) {
                if (result=="false"){
                    $("#msg").html("");
                    $("#btn").prop("disabled",false);
                }else {
                    $("#msg").html("该用户已经存在！,请重新输入");
                    $("#btn").prop("disabled",true);

                }

                }
        });

    }).focus(function () {
        $("#msg").html("");
        $("#btn").prop("disabled",false);
    });
   //  $(function () {
   //      $('#btn').click(function () {
   //
   //          $.ajax({
   //              type: "post",
   //              url: "/myBolg/user",
   //              contentType: "application/x-www-form-urlencoded; charset=utf-8",
   //              data: {
   //                  actionName: "updateUser",
   //                  nick: nickName,
   //                  mood:moodvar,
   //                  img:imgs
   //              },
   //          })
   //      })
   // })
        $('#btn').click(function () {
            $("#updateForm").submit();
        })
</script>
</body>
</html>